<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="ftl/css/bootstrap.min.css">
    <script src="ftl/js/jquery/jquery.min.js"></script>
    <script src="ftl/js/jquery.validation/1.14.0/jquery.validate.min.js"></script>
    <script src="ftl/js/jquery.validation/1.14.0/messages_zh.min.js"></script>
    <style>
        input.error {
            border: 1px solid #DB7023;
        }
    </style>
</head>
<body>
<div class="container">
    <form id="addUserForm">
        <br/>
        <div class="form-group">
            <label for="recordid">记录编号</label>
            <input type="text" class="form-control" id="recordid" name="recordid" placeholder="编号不能重复">
        </div>
        <div class="form-group">
            <label for="carid">车辆编号</label>
            <input type="text" class="form-control" id="carid" name="carid" placeholder="输入车辆编号">
        </div>
        <div class="form-group">
            <label for="initmile">发车里程</label>
            <input type="text" class="form-control" id="initmile" name="initmile" placeholder="发车里程">
        </div>
        <div class="form-group">
            <label for="initoil">发车油量</label>
            <input type="text" class="form-control" id="initoil" name="initoil" placeholder="发车油量">
        </div>
        <div class="form-group">
            <label for="repairaddress">维修地点</label>
            <input type="text" class="form-control" id="repairaddress" name="repairaddress" placeholder="维修地点">
        </div>
        <div class="form-group">
            <label for="usecartime">出车时间</label>
            <input type="date" class="form-control" id="usecartime" name="usecartime" placeholder="出车时间">
        </div>
        <div class="form-group">
            <label for="headman">经办人员</label>
            <input type="text" class="form-control" id="headman" name="headman" placeholder="经办人员">
        </div>
        <div class="form-group">
            <label for="headmobile">经办手机</label>
            <input type="text" class="form-control" id="headmobile" name="headmobile" placeholder="经办手机">
        </div>
        <div class="form-group">
            <label for="returntime">还车时间</label>
            <input type="text" class="form-control" id="returntime" name="returntime" placeholder="还车时间">
        </div>
        <div class="form-group">
            <label for="returnmile">还车里程</label>
            <input type="text" class="form-control" id="returnmile" name="returnmile" placeholder="还车里程">
        </div>
        <div class="form-group">
            <label for="returnoil">还车油量</label>
            <input type="text" class="form-control" id="returnoil" name="returnoil" placeholder="还车油量">
        </div>
        <div class="form-group">
            <label for="repairmoney">维修费用</label>
            <input type="text" class="form-control" id="repairmoney" name="repairmoney" placeholder="维修费用">
        </div>
        <div class="form-group">
            <label for="repaircontent">维修内容</label>
            <input type="text" class="form-control" id="repaircontent" name="repaircontent" placeholder="维修内容">
        </div>
        <div class="form-group">
            <label for="remark">备注信息</label>
            <input type="text" class="form-control" id="remark" name="remark" placeholder="备注信息">
        </div>
        <div class="form-group">
            <label for="addtime">添加时间系统时间</label>
            <input type="text" class="form-control" id="addtime" name="addtime" placeholder="添加时间系统时间">
        </div>
        <div class="form-group">
            <button type="button" id="save" class="btn btn-success">提交</button>
            <button type="button" id="cancelBtn" class="btn btn-default">取消</button>
        </div>
    </form>
</div>
<script>
    $("#save").click(function () {
        if (!check().form()) {
            return;
        }
        $.ajax({
            type: "POST",
            dataType: "json",
            url: '/repAdd',
            data: {
                recordid: $("#recordid").val(),
                carid: $("#carid").val(),
                initmile: $("#initmile").val(),
                initoil: $("#initoil").val(),
                repairaddress: $("#repairaddress").val(),
                usecartime: $("#usecartime").val(),
                headman: $("#headman").val(),
                headmobile: $("#headmobile").val(),
                returntime: $("#returntime").val(),
                returnmile: $("#returnmile").val(),
                returnoil: $("#returnoil").val(),
                repairmoney: $("#repairmoney").val(),
                repaircontent: $("#repaircontent").val(),
                remark: $("#remark").val(),
            },
            success: function (msg) {
                $("#cancelBtn").click();
            }
        });
    })


    $("#cancelBtn").click(function () {
        var index = parent.layer.getFrameIndex(window.name);
        parent.getUserPageList();
        parent.layer.close(index);
    });


    function check() {
        return $("#addUserForm").validate({
            rules: {
                userName: {
                    required: true
                },
                userPassword: {
                    required: true
                }
            },

            messages: {
                userName: {
                    required: ""
                },
                userPassword: {
                    required: ""
                }
            }
        });
    }
</script>
</body>
</html>